package com.yexiao.cofe.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yexiao.cofe.business.pojo.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author lkl
 * @since 2025/4/8
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    @Select("select * from role where role_name like concat('%', #{roleName}, '%')")
    Role selectRoleByRoleName(String roleName);

    List<Role> listRole(String roleName);

    void update(@Param("id") Integer id, @Param("roleName") String roleName, @Param("sort") Integer sort);

    @Select("select * from user_role where user_id = #{userId}")
    List<Role> listUserRole(@Param("userId") String userId);

    @Delete("delete from user_role where user_id = #{userId}")
    void delUserRole(@Param("userId") String userId);

    List<Role> listRoleByUserIdAndStoreId(@Param("userId") String userId, @Param("storeId") String storeId);
}
